<#assign base=request.contextPath />
<!DOCTYPE html>
<div class="row">
	<div class="col-md-12 col-sm-12 col-xs-12">
		<div class="x_panel">
			<div class="x_title">
		        <h2>系统分类管理 <small></small></h2>
		        <div class="clearfix"></div>
	        </div>
			<div class="x_content">
				<div class="row">
					<div class="col-sm-2">
						<button type="button" class="btn btn-primary" onclick="toAdd();"><i class="fa fa-plus"></i> 新增</button>
					</div>
					<div class="col-sm-10">
						<div class="pull-right">
							<label><input type="text" id="name" value="${name!''}" class="form-control input-sm" placeholder="请输入分类名"></label>
							<label>
								<select id="parentId" name="parentId" class="form-control select2">
		                        	<option value="">请选择</option>
		                        	<#list listParent as parent>
		                        	<option value="${parent.id?c}" <#if (parentId==parent.id)>selected="selected"</#if>>${parent.name}</option>
		                        	</#list>
	                    		</select>
	                    	</label>
							<button type="button" class="btn btn-dark" onclick="selectQuery('');"><i class="fa fa-search"></i> 查询</button>
						</div>
					</div>
				</div>
				<div class="table-responsive">
					<table class="table table-striped jambo_table bulk_action">
						<thead>
							<tr class="headings">
			                    <th class="column-title">分类名称 </th>
			                    <th class="column-title">排序 </th>
			                    <th class="column-title">是否删除</th>
			                    <th class="column-title">创建时间 </th>
			                    <th class="column-title">更新时间 </th>
			                    <th class="column-title">创建人 </th>
			                    <th class="column-title">修改人 </th>
			                    <th class="column-title no-link last"><span class="nobr">操作</span></th>
			                </tr>
						</thead>
			            <tbody>
			            	<#list page.content as obj>
			            	<tr class="even pointer">
			                    <td class=" ">${(obj.name)!'' }</td>
			                    <td class=" ">${(obj.sort?c)!0 }</td>
			                    <td class=" ">
			                    	<#if (obj.isDelete==0)>未删</#if>
			                    	<#if (obj.isDelete==1)><span style="color:red;">已删</span></#if>
			                    </td>
			                    <td class=" ">${(obj.createTime)!'' }</td>
			                    <td class=" ">${(obj.updateTime)!'' }</td>
			                    <td class=" ">${(obj.creator)!'' }</td>
			                    <td class=" ">${(obj.updator)!'' }</td>
			                    <td class="last">
			                    	<button type="button" class="btn btn-warning btn-xs" onclick="toEdit(${(obj.id)?c});"><i class="fa fa-edit"></i> 编辑</button>
			                    	<#if (obj.isDelete==0)>
			                    	<button type="button" class="btn btn-danger btn-xs" onclick="doDelete(${(obj.id)?c});"><i class="fa fa-close"></i> 删除</button>
			                    	</#if>
			                    	<#if (obj.isDelete==1)>
			                    	<button type="button" class="btn btn-warning btn-xs" onclick="doRecovery(${(obj.id)?c});"><i class="fa fa-repeat"></i> 恢复</button>
			                    	</#if>
			                    </td>
			                </tr>
			                </#list>
			            </tbody>
					</table>
				</div>
			</div>
			<#include "../common/paginator.ftl" />
		</div>
	</div>
</div>
<script type="text/javascript">
//select2
$(".select2").select2({width: "100%"});
/*进入添加*/
function toAdd(){
	$("#main_content").load('${base}/gx/sysClassify/toAdd');	
}

/*进入编辑*/
function toEdit(id){
	$("#main_content").load('${base}/gx/sysClassify/toEdit',{"id":id});	
}

/*删除*/
function doDelete(id){
	 swal({
		title: "删除",
		text: "您确定删除该分类吗？",
		type: "warning",
		cancelButtonText:"取消",
		showCancelButton: true,
		confirmButtonColor: "#DD6B55",
		confirmButtonText: "确定",
		closeOnConfirm: false
	}, function(){
		$.post('${base}/gx/sysClassify/delete',{"id":id},function(data) {
			swal(data.msg);
			if (data.flag) {
				$("#main_content").load('${base}/gx/sysClassify/list');
			}
		});
	});
}

/*恢复*/
function doRecovery(id){
	 swal({
		title: "恢复",
		text: "您确定恢复该分类吗？",
		type: "warning",
		cancelButtonText:"取消",
		showCancelButton: true,
		confirmButtonColor: "#DD6B55",
		confirmButtonText: "确定",
		closeOnConfirm: false
	}, function(){
		$.post('${base}/gx/sysClassify/recovery',{"id":id},function(data) {
			swal(data.msg);
			if (data.flag) {
				$("#main_content").load('${base}/gx/sysClassify/list');
			}
		});
	});
}

function selectQuery(pageIndex){
	var data = {
		"pageIndex":pageIndex,
		//其余查询条件自行添加
		"name":$.trim($("#name").val()),
		"parentId":$.trim($("#parentId").val()),
	};
	$("#main_content").load('${base}/gx/sysClassify/list',data);	
}
</script>
